package com.demo;

import java.io.File;
import java.util.Arrays;
import java.util.Collection;

import com.experitest.client.Client;

import org.junit.*;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

@RunWith(Parameterized.class)
public class Eribank {
    private String host = "localhost";
    private int port = 8888;
    private String projectBaseDirectory = "./project";
    protected Client client = null;

    private String device;
    private String app;
    
    public Eribank(String device, String app) {
		this.device = device;
		this.app = app;
	}
        
    @Before
    public void setUp(){
        client = new Client(host, port);
                
        client.setProjectBaseDirectory(new File(projectBaseDirectory).getAbsolutePath());
        client.setReporter("xml", "reports", "demo");
    }

    @Parameterized.Parameters
    public static Collection getDevices() {
    	return Arrays.asList(new Object[][] {
                { "adb:Galaxy2", "com.experitest.ExperiBank/.LoginActivity" },
                { "ios_app:iPod", "search:EriBank" }
        });
    }
    
    @Test
    public void basicLogin(){
        client.setApplicationTitle(device);
        client.launch(app, true, false);
        
        client.elementSendText("default", "Username", 0, "company");
        client.elementSendText("default", "Password", 0, "company");
        client.click("default", "Login", 0, 1);
        client.click("default", "Logout", 0, 1);
    }
    
    @After
    public void tearDown(){
        client.generateReport();
    }
}
